﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Summerset.Isbndb.Subjects
{
    /// <summary>
    /// Shows what the subject consists of.
    /// </summary>
    public sealed class SubjectElementStructure : ResponseElementChildBase
    {
        #region Constructor + Overridden Properties

        /* Example Element:
         * <SubjectElement text="Artificial intelligence" type="Topical Term" marc_subfield="a"/> */

        /// <summary>
        /// Initializes a new instance of the <see cref="SubjectElementStructure"/> class.
        /// </summary>
        /// <param name="structureElement">The xml element containing the underlying data for this instance.</param>
        public SubjectElementStructure(XmlElement structureElement)
            : base(structureElement) { }

        /// <summary>
        /// Gets the name of the xml element that is expected by this class's consturctor.
        /// </summary>
        protected override string ExpectedElementName
        {
            get { return "SubjectElement"; }
        }

        #endregion
        #region Properties

        /// <summary>
        /// Literal text of the subject element. Typically, but not in all cases, subject name is formed by combining texts of its elements separated by double-dash.
        /// </summary>
        public string Text
        {
            get { return _element.Attributes["text"].Value; }
        }

        /// <summary>
        /// An ISBNdb.com specific type loosely based on the MARC field and subfield information.
        /// </summary>
        public string Type
        {
            get { return _element.Attributes["type"].Value; }
        }

        /// <summary>
        /// MARC subfield symbol, where available.
        /// </summary>
        public string MarcSubfield
        {
            get { return _element.Attributes["marc_subfield"].Value; }
        }

        #endregion
    }
}
